import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
  id?: number;
  projectId?: number;
  projectName?: string;
  planId?: number;
  missionName?: string;
  missionStatus?: number;
  cycleValue?: number;
  cycleUnit?: number;
  finishDate?: string;
  inspectResult?: number;
  inspectUser?: string;
};
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = "/business/inspection/v2/inspection/missions";
const Url = "/business/inspection/v2/inspection/mission";
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
//巡检任务弹窗列表
export const getTaskList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>(
    "get",
    "/business/inspection/v2/inspection/mission/facilites",
    {
      params
    }
  );
};
//派发工单
export const sendOrder = (data?: object) => {
  return http.request<commonResult<any>>(
    "post",
    "/business/inspection/v2/inspection/mission/work-order",
    {
      data
    }
  );
};
//自动派发
export const autoSendOrder = (data?: object) => {
  return http.request<commonResult<any>>(
    "post",
    "/business/inspection/v2/inspection/mission/auto-dispatch-work-order",
    {
      data
    }
  );
}
//获取设备命令下拉框
export const getDeviceCommand = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/product/v2/commands",
    {
      params
    }
  );
}